import os
import logging
import logging.config


def get_logger(name, plog_conf="logging.conf"):
    """
    :param name: logger name
    :param plog_conf: logging config file path
    :param write_log_path: write log file path
    """
    #if not os.path.exists(write_log_path):
    #    os.mkdir(write_log_path)
    #logging.basicConfig(level=logging.DEBUG, encoding="utf-8")
    logging.config.fileConfig(plog_conf, disable_existing_loggers=False)
    logger = logging.getLogger(name)
    return logger



if __name__ == "__main__":
    # 只输出到控制台
    log = get_logger("debug")
    # # 只输出到文件
    # log = get_logger("crawler")
    # # 同时输出到控制台和文件
    # log = get_logger("root")
    log.debug("test debug")
    log.info("test info")
    log.warning("test warning")
    log.error("test error")
    log.critical("test critical")